package com.tpc.control.jpa;

import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * ReserveItemGreige entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "reserve_item_greige", catalog = "production_control", uniqueConstraints = @UniqueConstraint(columnNames = {
		"reserve_no", "reserve_line", "production_no", "seq" }))
public class ReserveItemGreige implements java.io.Serializable {

	// Fields

	private Integer running;
	private ReserveItem reserveItem;
	private CommonData commonData;
	private String remark;
	private Timestamp createDate;
	private String createBy;
	private Set<ReserveItemSale> reserveItemSales = new HashSet<ReserveItemSale>(
			0);

	// Constructors

	/** default constructor */
	public ReserveItemGreige() {
	}

	/** minimal constructor */
	public ReserveItemGreige(ReserveItem reserveItem, CommonData commonData,
			Timestamp createDate, String createBy) {
		this.reserveItem = reserveItem;
		this.commonData = commonData;
		this.createDate = createDate;
		this.createBy = createBy;
	}

	/** full constructor */
	public ReserveItemGreige(ReserveItem reserveItem, CommonData commonData,
			String remark, Timestamp createDate, String createBy,
			Set<ReserveItemSale> reserveItemSales) {
		this.reserveItem = reserveItem;
		this.commonData = commonData;
		this.remark = remark;
		this.createDate = createDate;
		this.createBy = createBy;
		this.reserveItemSales = reserveItemSales;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "running", unique = true, nullable = false)
	public Integer getRunning() {
		return this.running;
	}

	public void setRunning(Integer running) {
		this.running = running;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns( {
			@JoinColumn(name = "reserve_no", referencedColumnName = "reserve_no", nullable = false),
			@JoinColumn(name = "reserve_line", referencedColumnName = "reserve_line", nullable = false) })
	public ReserveItem getReserveItem() {
		return this.reserveItem;
	}

	public void setReserveItem(ReserveItem reserveItem) {
		this.reserveItem = reserveItem;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumns( {
			@JoinColumn(name = "production_no", referencedColumnName = "production_no", nullable = false),
			@JoinColumn(name = "seq", referencedColumnName = "seq", nullable = false) })
	public CommonData getCommonData() {
		return this.commonData;
	}

	public void setCommonData(CommonData commonData) {
		this.commonData = commonData;
	}

	@Column(name = "remark", length = 45)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "create_date", nullable = false, length = 19)
	public Timestamp getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Timestamp createDate) {
		this.createDate = createDate;
	}

	@Column(name = "create_by", nullable = false, length = 20)
	public String getCreateBy() {
		return this.createBy;
	}

	public void setCreateBy(String createBy) {
		this.createBy = createBy;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "reserveItemGreige")
	public Set<ReserveItemSale> getReserveItemSales() {
		return this.reserveItemSales;
	}

	public void setReserveItemSales(Set<ReserveItemSale> reserveItemSales) {
		this.reserveItemSales = reserveItemSales;
	}

}